#!/bin/sh

set -e

SYNTAX='/usr/share/mc/syntax/Syntax'

# Start magenta at boot time
#
if [ -x "/etc/init.d/magenta" ]; then
	update-rc.d magenta start 39 S . >/dev/null
fi

# Patch mcedit's syntax
#
# Maybe this way is not the best, but I can't think of anything else now. It seems to work anyway.
#
if [ -f "$SYNTAX" ] && ! grep -q 'magenta.syntax' "$SYNTAX"; then
	sed -i '1,/^include/ {s/\(^include.*$\)/\1\nfile ..\\*\\\\.(magenta)$ Magenta\\srules ^##magenta$\ninclude magenta.syntax/}' "$SYNTAX"
fi

exit 0
